package com.pti.usermanager.web.controller;

import com.pti.usermanager.service.api.IconService;
import com.pti.usermanager.web.dto.request.UpdateSort;
import com.pti.usermanager.web.dto.response.ResultResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: IconController
 * @Author: liumengyao
 * @Description: 图标控制层
 * @Date: 2019/3/5
 */
@RestController
@Api(value = "图标管理接口", tags = "提供图标的管理接口")
@CrossOrigin
public class IconController {

    private static final Logger logger = LogManager.getLogger(IconController.class);

    @Autowired
    private IconService iconService;

    @GetMapping("/icon/findAll")
    @ApiOperation(value = "获取上侧图标列表", notes = "获取上侧图标列表", produces = "application/json")
    public ResultResponse findAll(@RequestParam Integer iconTyp){

        logger.debug("iconTyp:{}",iconTyp);

        return iconService.findAll(iconTyp);
    }

    @GetMapping("/icon/findIconByUidAndIt")
    @ApiOperation(value = "获取上侧分配图标", notes = "获取上侧分配图标", produces = "application/json")
    public ResultResponse findBranchData(@RequestParam Long usrId,
                                         @RequestParam Integer iconTyp){

        logger.debug("usrId:{} iconTyp:{}",usrId,iconTyp);
        return iconService.findBranchData(usrId,iconTyp);
    }

    @PostMapping("/icon/moveIcon")
    @ApiOperation(value = "添加上侧与右侧图标", notes = "添加上侧与右侧图标", produces = "application/json")
    public ResultResponse moveIcon(@RequestBody UpdateSort updateSort,
                                   @RequestParam Long usrId,
                                   @RequestParam Integer iconTyp){
        return iconService.moveIcon(updateSort,usrId,iconTyp);
    }

    @GetMapping("/icon/leftFindAll")
    @ApiOperation(value = "获取左侧部门图标", notes = "获取左侧部门图标", produces = "application/json")
    public ResultResponse leftFindAll(@RequestParam Long usrId,
                                      @RequestParam Integer iconTpy){
        return iconService.findLeftIconByUsrId(usrId,iconTpy);
    }

    @GetMapping("/icon/rigthFindAll")
    @ApiOperation(value = "获取右侧部门图标", notes = "获取右侧部门图标", produces = "application/json")
    public ResultResponse findRightIconByUsrId(){
        return null;
    }





}
